package nc.bs.cartask;

import nc.bs.dao.BaseDAO;
import nc.itf.cartask.ICartaskBO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.trade.pub.IBillStatus;
import nc.vo.yyam.cartask.AggCartaskVO;
import nc.vo.yyam.cartask.CartaskBVO;
import nc.vo.yyam.cartask.CartaskHVO;

public class CartaskBO implements ICartaskBO {
	BaseDAO dao = null;

	public BaseDAO getDao() {
		if (dao == null) {
			dao = new BaseDAO();
		}
		return dao;
	}
	public boolean returnCar(AggCartaskVO vo, String curUser) throws BusinessException {
		CartaskHVO hvo=(CartaskHVO) vo.getParentVO();
		CartaskBVO[] bvos=(CartaskBVO[]) vo.getChildrenVO();
		boolean isallreturn=true;
		for(CartaskBVO bvo : bvos){
			if(bvo.getIs_return()==null||bvo.getIs_return().compareTo(UFBoolean.FALSE)==0){
				isallreturn=false;
			}
		}
		if(isallreturn){
			hvo.setIs_return(UFBoolean.TRUE);
			hvo.setReturndate(new UFDate());
			hvo.setVbillstatus(IBillStatus.ENDED);
		}
		getDao().updateVO(hvo);
		getDao().updateVOArray(bvos) ;
		return false;
	}

}
